/*
--------------------------------------------------------------------------------
	This do file creates Tables 1 and 2 and Figure S1 from
	"Lies in politics: A study of politicians' preferences for truth-telling".
	Before running this do file, readers should update the directory below 
	called "Home" to where the "ReplicationPackage" folder is located.
	
	Please note that due to standardization of the variables age,
	log population size and rounding of the variable margin2015, there is slight
	deviation in the decimals of the coefficients. This also slightly affects the
	fitted values.
	
	Paper: "Lies in politics: A study of politicians' preferences for truth-telling"
	Authors: Katharina A. Janezic, Aina Gallego
	Corresponding author: Aina Gallego, agallego@ibei.org
	
	Last changed: June 6, 2020
--------------------------------------------------------------------------------
*/

*----- 0: Housekeeping
clear all
version 13
set more off

*------------------------------------------------------------------------------*
/* PLEASE UPDATE THE DIRECTORY HERE */
/* For Mac Users */
//cd "Users/.../Replication/code"

/* For Windows Users */
//cd "C:\...\Replication\code"
*------------------------------------------------------------------------------*


*------------------------------------------------------------------------------*
*----- 0: Load data
use "./dataRepl.dta", replace

*----- subsample used
drop if interestreport==. //5 observations
drop if honestytime_cutoff==1 //spent less or equal to 5 seconds on answering honesty question
drop if honestytime_cutoff==3 | honestytime_cutoff==4 //spent more than 90 seconds on answering honesty question


*------------------------------------------------------------------------------*
*---- 1: Regressions Table 1

*** Table 1(1)
quietly reg iscara interestreportYes gender
predict fitval_gender1
eststo gender1

*** Table 1(2)
quietly reg iscara interestreportYes gender pop_log age margin2015
predict fitval_gender2
eststo gender2

*** Table 1(3)
quietly reg iscara interestreportYes isMajorParty
predict fitval_party1
eststo party1

*** Table 1(4)
quietly reg iscara interestreportYes isMajorParty pop_log age margin2015
predict fitval_party2
eststo party2

*** Table 1(5)
quietly reg iscara interestreportYes gender isMajorParty pop_log age margin2015
predict fitval_combined
eststo combined

*** Display and Export Table
esttab gender* party* combined*, label se b(2) starlevels( * 0.10 ** 0.05 *** 0.01) mtitles("Rep. Heads" "Rep. Heads" "Rep. Heads" "Rep. Heads" "Rep. Heads")
esttab gender* party* combined* using table1.tex, replace label se b(2) starlevels( * 0.10 ** 0.05 *** 0.01) mtitles("Rep. Heads" "Rep. Heads" "Rep. Heads" "Rep. Heads" "Rep. Heads")


*------------------------------------------------------------------------------*
*---- 2: Regressions Table 2

*** Table 2(1)
quietly reg reelected iscara
predict fitval_reelection1
eststo reelection1

*** Table 2(2)
quietly reg reelected iscara ranagain margin2015 gender pop_log b2.party
predict fitval_reelection2
eststo reelection2

*** Table 2(3)
quietly reg reelected iscara ranagain margin2015 c.margin2015#iscara gender pop_log b2.party
predict fitval_reelection3
eststo reelection3

*** Table 2(4)
quietly reg reelected iscara  margin2015 c.margin2015#iscara gender pop_log b2.party if ranagain==1
predict fitval_altreelection
eststo altreelection


*** Display and Export Table
esttab reelection* altreelection*, label se b(2) starlevels( * 0.10 ** 0.05 *** 0.01)
esttab reelection* altreelection* using table2.tex, replace label se b(2) starlevels( * 0.10 ** 0.05 *** 0.01)



*------------------------------------------------------------------------------*

*---- 3: Check if fitted values of regressions are bounded
keep fitval_* row_id
reshape long fitval_, i(row_id) j(reg) string

hist fitval_, percent ///
bcolor(navy) gap(0.05) barwidth(0.02)  ///
xtick(0(0.1)1.1) xlabel(0(0.1)1.1) ///
ytitle("Frequency in %") xtitle("Fitted Values") ///
graphregion(color(white)) bgcolor(white) ///
title("Pooled fitted values for all linear probability regressions") legend(off)
graph export figureS1.pdf, replace
